package com.example.day12_7_12_4;

import android.util.Log;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.day12_7_12_4.adapter.InfoRclAdapter;
import com.example.day12_7_12_4.base.BaseActivity;
import com.example.day12_7_12_4.base.BasePresenter;
import com.example.day12_7_12_4.bean.NaviBean;
import com.example.day12_7_12_4.presenter.MPresenter;
import com.example.day12_7_12_4.view.MView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity implements MView<NaviBean> {

    private RecyclerView rcl;
    private InfoRclAdapter infoRclAdapter;

    @Override
    protected BasePresenter initPresenter() {
        return new MPresenter();
    }

    @Override
    protected void initData() {
        mPresenter.getData();
    }

    @Override
    protected void initView() {
        rcl = findViewById(R.id.rcl);
        rcl.setLayoutManager(new LinearLayoutManager(this));
        List<NaviBean> list = new ArrayList<>();
        infoRclAdapter = new InfoRclAdapter(this, list);
        rcl.setAdapter(infoRclAdapter);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void setData(NaviBean naviBean) {
        Log.i("7-12", "setData: " + naviBean.getData().toString());
        infoRclAdapter.setData(naviBean.getData());
    }
}
